import 'package:flutter/material.dart';

class LeftSlideInButton extends StatelessWidget {
  final Widget Function(BuildContext) myPageBuilder;
  final Icon icon;

  const LeftSlideInButton({
    super.key,
    required this.myPageBuilder, required this.icon,
  });

  @override
  Widget build(BuildContext context) {
    return IconButton(
      icon: icon,
      onPressed: () {
        (
          Navigator.push(
            context,
            PageRouteBuilder(
              pageBuilder: (context, _, __) => myPageBuilder(context),
              transitionsBuilder: (_, anim, __, child) {
                const offset = Offset(1.0, 0.0);
                return SlideTransition(
                  position: Tween<Offset>(
                    begin: offset,
                    end: Offset.zero,
                  ).animate(anim),
                  child: child,
                );
              },
              transitionDuration: const Duration(milliseconds: 250),
            ),
          ),
        );
      },
    );
  }
}
